package com.seuic.scannerapitest.activity;

import android.content.Context;

public class InnerScanner{
	private static Context mContext = null;
	private static InnerScanner mInnerScanner = null;
	private static InnerScannerI mInnerScannerI = null;
	private InnerScanner(){
	};
	public static InnerScanner getInstance(Context context){
		mContext = context;
		if(mInnerScanner == null){
			mInnerScanner = new InnerScanner();
		}
		if(mInnerScannerI == null){
			mInnerScannerI = new InnerScannerImpl(context);
		}
		return mInnerScanner;
	}
	/**
	 * 启动扫码
	 * @param timeout
	 */
	public void start(int timeout) {
		mInnerScannerI.start(timeout);
	}
	/**
	 * 停止扫码，关闭扫描红外线
	 */
	public void stop() {
		mInnerScannerI.stop();
	}
	
	public void setOnScanListener(OnScanListener onScanListener) {
		mInnerScannerI.setOnScanListener(onScanListener);
	}

	public void stopListen() {
		mInnerScannerI.setOnScanListener(null);
	}
	
	public void close(){
		mInnerScannerI.close();
	}
	
	/**
	 * 静默安装
	 * @param zipPath
	 * @return
	 */
	public boolean silentInstall(String zipPath){
		return mInnerScannerI.silentInstall(zipPath);
	}
	
	/**
	 * 设置虚拟按键屏蔽状态
	 * @param disableMask
	 * @return
	 */
	boolean setVirKeyDisabled(int disableMask){
		return mInnerScannerI.setVirKeyDisabled(disableMask);
	}
	
	/**
	 * 设置禁用home键
	 * @return
	 */
	void setHomeDisable(){
		mInnerScannerI.setHomeDisable();
	}
	
	/**
	 * 设置禁用返回键
	 * @return
	 */
	void setBackDisable(){
		mInnerScannerI.setBackDisable();
	}
	
	/**
	 * 设置禁用菜单键
	 * @return
	 */
	void setMenuDisable(){
		mInnerScannerI.setMenuDisable();
	}
	
	/**
	 * 获取虚拟按键屏蔽状态
	 * @return
	 */
	int getVirKeyDisabled(){
		return mInnerScannerI.getVirKeyDisabled();
	}
	
	/**
	 * 获取系统状态栏是否允许下拉的状态
	 * @return
	 */
	int getStatusBarEnabled(){
		return mInnerScannerI.getStatusBarEnabled();
	}
	
	/**
	 * 设置系统状态栏是否允许下拉
	 * @param enable
	 */
	void setStatusBarEnabled(int enable){
	     mInnerScannerI.setStatusBarEnabled(enable);
	}
}
